package com.windea.breezeframework.javafx.extensions

import java.awt.image.*
import java.io.*
import javax.imageio.*
import javax.imageio.stream.*

fun BufferedImage.setRGB(xRange: IntRange, yRange: IntRange, rgb: Int) {
	for(x in xRange) {
		for(y in yRange) {
			this.setRGB(x, y, rgb)
		}
	}
}

fun BufferedImage.writeTo(file: File, formatName: String = file.extension) = ImageIO.write(this, formatName, file)

fun BufferedImage.writeTo(outputStream: OutputStream, formatName: String) = ImageIO.write(this, formatName, outputStream)

fun BufferedImage.writeTo(outputStream: ImageOutputStream, formatName: String) = ImageIO.write(this, formatName, outputStream)
